package com.qf.Myconfig;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;

//这是我指定的规矩
/**
 * @author wbzs,
 * @date 2022/10/20,
 * @time 21:30,
 * 如果被main扫描到就是全局配置；
 */
@A
@Configuration
public class MyRibbonConfig {

    /*
    修改负载均衡的规则
     */

    @Bean
    //多例对象
    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
    public IRule createIrule(){
        //修改为随机
        return  new RandomRule();
    }
}
